﻿using System;
using System.Xml.Serialization;
using TiPort.TiEntityObjects;
using TI;
using TI_EntityLib.TiEntityObjects;

namespace TiEntityObject.Contract
{
    public class ContractProcedure : MongoEntity, IDbRootObject
    {
        [XmlElement("id")]
        public Int64  ID { get; set; }

        public string Key { get { return ID.ToString(); } }

        [XmlElement("regNum")]
        public string RegNum { get; set; }

        [XmlElement("regNum807")]
        public string regNum807 { get; set; }

        [XmlElement("status")]
        public string Status { get; set; }

        [XmlElement("reason")]
        public string Reason { get; set; }

        [XmlElement("executions")]
        [LinkObjectAttribute(IsCollection = true)]
        public ContractProcedureExecutions Executions { get; set; }

        [XmlElement("terminations")]
        [LinkObjectAttribute(IsCollection = true)]
        public ContractProcedureTermenations Terminations { get; set; }

                
        public DateTime LastUpdateDate { get { return DateTime.Now; } set { ;} }
        public long iLastUpdateDate { get { return Helper.Time.GetDateInMS(LastUpdateDate); } }


        public string FileName { get; set; }

        public bool IsFarmObject { get { return true; } }

        public string ObjectType { get; set; }

        #region IDbRootObject Members

        public long iFileDate { get; set; }

        public override string GetAsJson()
        {
            return Helper.Json<ContractProcedure>.NewtonSerializeObject(this);
        }

        override public string GetInsertScript()
        {
            string v = GetAsJson();
            return "mergeContractProcedure(" + v + ")";
        }

        #endregion

        public TiEntityClass Class
        {
            get { return TiEntityClass.Pharm; }
        }

        string IDbRootObject.ObjectType
        {
            get;
            set;
        }


        public long iTransportDay
        {
            get;
            set;
        }
    }
}
